<script type="text/javascript">
  
    function printPage(id) {
        var html="<fieldset>";
        html+= document.getElementById(id).innerHTML;
        html+="</fieldset>";

        var printWin = window.open('','','left=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status =0');
        printWin.document.write(html);
        printWin.document.close();
        printWin.focus();
        printWin.print();
        printWin.close();

  
    }
</script>
   
<div class="jumbotron">
    <table class="btl-search">
        <tr>
            <td></td>
            <td><h3 class="report-h">Leave Request Report</h3></td>
            <td>
				<div id="report">
					<?php
					if ($this->session->userdata('valid')) {
						echo $this->session->userdata('valid');
						echo $this->session->unset_userdata('valid');
					} else if ($this->session->userdata('valid_num')) {
						echo $this->session->userdata('valid_num');
						echo $this->session->unset_userdata('valid_num');
					}
					echo form_open('report/find_date_report');
            echo '<b>From:</b>
            <input  type="text" id="startdate" class="input-small" title="From Date" /> 
             <input type="hidden" name="s_date" id="start_alternate" />
	<b>To:</b>
		<input  type="text" id="enddate" class="input-small" title="To Date" />
                <input type="hidden" name="e_date" id="end_alternate" />
		<input name="btn_submit" type="submit" class="my_search" value="" title="Search" />
	';
					echo form_close();
					?>


					<div style="float:right;">
						<?php echo anchor('report/year', form_button('btn_rcd_dept', 'Year', 'class="btn btn-info"'), array('style' => 'text-decoration:none; color:#5C9416;')); ?>

						<?php echo anchor('report/monthly', form_button('btn_rcd_dept', 'Month', 'class="btn btn-info"'), array('style' => 'text-decoration:none; color:#5C9416;')); ?>

						<div class="btn-group">
							<a class="btn dropdown-toggle btn-info" data-toggle="dropdown" href="#">
								Semester
								<span class="caret"></span>
							</a>
							<ul class="dropdown-menu">
								<li><?php echo anchor('report/semester1', 'Semester 1'); ?></li>
								<li><?php echo anchor('report/semester2', 'Semester 2'); ?></li>
							</ul>
						</div>

					</div> 
				</div>
			</td></tr>
	</table>
	<div class="cleaner"></div>
    <br/>
    <div style="float: right; color: #239DA9;">
To print this report, Click here<a href="#">
    <img src="<?php echo base_url(); ?>/images/print.png" align="center" onclick="return printPage('year');" id="image"  alt="Print semester report" title="Print semester report"/>
</a>
</div>	
    </br>
	<hr/>

<div class="row-fluid">
	<div id="spna3-rpt" class="span3" style="background: #E4E4E4">
		<ul class="nav nav-list">
			<li class="nav-header">Employee</li>
			<?php
			$current = ($this->uri->segment(3) ? $this->uri->segment(3) : 0);
			foreach ($employee as $data) {
				if ($data->staff_id === $current) {
					echo '<li class="active">' . anchor('report/show_report/' . $data->staff_id, strtoupper($data->emp_lname) . ' ' . ucfirst($data->emp_fname)) . '</li>';
				} else {
					echo '<li>' . anchor('report/show_report/' . $data->staff_id, strtoupper($data->emp_lname) . ' ' . ucfirst($data->emp_fname)) . '</li>';
				}
			}
			?>
		</ul>
	</div>

	<div id="span9-rpt" class="span9">
		

<?php
		echo '<fieldset id="year" style="border:1px solid #239DA9 ;margin: 0 auto;width:96%;height: auto; padding:20px;border-radius:5px;">';
	
		echo form_open('report/show_report/');
		if ($report) {
			?>
			<table class="table table-bordered" border="1" cellpadding="0" cellspacing="0" style="width: 100%;" >
				<thead>
					<tr class="head-info">
						<th colspan="4" class="summary">Detail</th>
						<th colspan="2" class="summary">Type of Leave</th>
						<th colspan="3" class="summary">Sub Type of Leave</th>
					</tr>
					<tr class="head-info2">
						<th class="summary">Staff_Name</th>
						<th class="summary">Gender</th>
						<th class="summary">Start Date</th>
						<th class="summary">End Date</th>
						<th class="summary">Annual</th>
						<th class="summary">Catch Up</th>
						<th class="summary">Impossed</th>
						<th class="summary">Personal</th>
						<th class="summary">Special</th>
					</tr>
				</thead>
				<tbody>
					<?php
					foreach ($staff as $row) {
						?>
						<tr>
							<td class="name_in_rpt" rowspan="<?php echo $total_rows; ?>"><span class="txt-bold-name"><?php echo strtoupper($row->emp_lname) . nbs() . ucfirst($row->emp_fname); ?></span></td>
							<td rowspan="<?php echo $total_rows; ?>"><?php echo $row->emp_gender; ?></td>
							<?php
							foreach ($report as $rows) {
								?>
								<td class="summary"><?php echo $rows->start_date; ?></td>
								<td class="summary"><?php echo $rows->end_date; ?></td>	

								<?php
								if ($rows->lea_alias === 'catchup') {
									?>
									<td>&nbsp;</td>
									<?php
									if ($num_catchup) {
										?>
										<td class="summary num"><?php echo $rows->duration; ?></td>
										<?php
									} else {
										?>
										<td>&nbsp;</td>
										<?php
									}
									?>
									<td>&nbsp;</td>
									<td>&nbsp;</td>
									<td>&nbsp;</td>
									<?php
								} else if ($rows->lea_alias === 'annual') {
									if ($num_annual) {
										?>
										<td class="summary num"><?php echo $rows->duration; ?></td>
										<?php
									} else {
										?><td>&nbsp;</td><?php } ?>
									<td>&nbsp;</td>
									<?php
									// Start impossed and impossed  = TRUE
									if ($rows->stl_alias === 'impossed') {
										if ($impossed) {
											?>
											<td class="summary num"><?php echo $rows->duration; ?></td>
										<?php } else { ?>
											<td>&nbsp;</td>
											<?php
										}
										?>
										<td>&nbsp;</td>
										<td>&nbsp;</td>
										<?php
									} else if ($rows->stl_alias === 'personal') {
										?>
										<td>&nbsp;</td>
										<?php if ($personal) { ?>
											<td class="summary num"><?php echo $rows->duration; ?></td>
										<?php } else { ?>
											<td>&nbsp;</td>
										<?php } ?>
										<td>&nbsp;</td>
										<?php
									} else if ($rows->stl_alias === 'special') {
										?>
										<td>&nbsp;</td>
										<td>&nbsp;</td>
										<?php if ($special) { ?>
											<td class="summary num"><?php echo $rows->duration; ?></td>
										<?php } else { ?>
											<td>&nbsp;</td>
											<?php
										}
									} //End impossed
								}
								?>
			</tr>
							<?php
						}
						?>
						<tr>
							<td class="txt-total" colspan="4">Sub Total :</td>
							<td class="summary num"><?php echo $total_annual; ?></td>
							<td class="summary num"><?php echo $total_catchup; ?></td>
							<td class="summary num"><?php echo $total_impossed; ?></td>
							<td class="summary num"><?php echo $total_personal; ?></td>
							<td class="summary num"><?php echo $total_special; ?></td>
		<!--						<td>total</td>-->
						</tr>
						<tr>
							<td class="txt-total" colspan="4">Total :</td>
							<td colspan="5" class="num">
								<?php
								$total = ($total_annual + $total_catchup);

								echo $total;
								?>
							</td>
						</tr>
						<?php
					}
					?>
				</tbody>
			</table>
			<?php
		} else {
			?>
			<table>
				<tr>
					<td>No result of report!</td>
				</tr>
			</table>
			<?php
		}
		echo form_close();
		?>
        </fieldset>
	</div>
</div>
<div class="row-fluid">
	<?php $this->load->view('report/summary'); ?>
</div>
</div>
